<?php

/**
 * @category   MM
 * @package    MM_Service
 */
class MM_Service_Facade extends Mediad2_Service_Abstract
{
	/**
	 * const 
	 */
	
	/**
	 * var
	 */	
	
	/**
	 * 初始化
	 */
	public function init()
	{		
	}
	
	//----------------------------------------
	// 公共方法
	//----------------------------------------
	
	/**
	 * check version
	 * @param string $deviceVersion
	 * @return Mediad2_Model_Result
	 */
	public function checkVersion($deviceVersion)
	{
		$service = new Mediad2_Service_Admin_Version();
		return $service->checkVersion($deviceVersion);
	}
	
	/**
	 * 根据指定的eid和synctime，进行sync
	 * @param array $params 一维数组，每个元素由eid和synctime两项构成，如$arrParams[]=array('eid'=>1,'synctime'=>xxx);
	 * @return Mediad2_Model_Result
	 */
	public function sync(array $params) 
	{
		$service = new MM_Service_Admin_EventSync();
		return $service->sync($params);
	}
	
	/**
	 * 用户注册（通过昵称）
	 * @param string $nickname
	 * @return Mediad2_Model_Result
	 */
	public function register($nickname,$imei)
	{
		$service = new Mediad2_Service_Admin_User();
		return $service->registerByNickname($nickname,$imei);
	}

	/**
	 * 用户登录
	 * @param string $email
	 * @param string $pwd
	 * @return Mediad2_Model_Result
	 */
	public function login($email, $pwd)
	{		
		$service = new Mediad2_Service_Admin_User();
		return $service->loginReturnAuth($email, $pwd);
	}
	
	/**
	 * binding by email
	 * @param int $uid
	 * @param string $email
	 * @param string $pwd
	 * @return Mediad2_Model_Result
	 */
	public function bindingByEmail($uid, $email, $pwd)
	{
		$service = new Mediad2_Service_Admin_User();
		return $service->bindingByEmail($uid, $email, $pwd);
	}
	
	/**
	 * binding by mobile
	 * @param int $uid
	 * @param string $mobile
	 * @return Mediad2_Model_Result
	 */
	public function bindingByMobile($uid, $mobile)
	{
		$service = new Mediad2_Service_Admin_User();
		return $service->bindingByMobile($uid, $mobile);
	}
	
	/**
	 * 上传用户头像
	 * @param int $uid
	 * @return Mediad2_Model_Result
	 */
	public function uploadUserimg($uid)
	{
		$service = new Mediad2_Service_Admin_User();
		return $service->uploadUserimg($uid);
	}
	
	/**
	 * 上传用户背景图片
	 * @param int $uid
	 * @return Mediad2_Model_Result
	 */
	public function uploadUserSpaceImg($uid)
	{
		$service = new Mediad2_Service_Admin_User();
		return $service->uploadUserSpaceImg($uid);
	}
	
	/**
	 * 更新用户信息
	 * @param Mediad2_Model_User $user
	 * @return Mediad2_Model_Result
	 */
	public function updateUserInfo(Mediad2_Model_User $user)
	{	
		$service = new Mediad2_Service_Admin_User();
		return $service->update($user);
	}
	
	/**
	 * 获取用户信息
	 * @param int $uid
	 * @return Mediad2_Model_Result
	 */
	public function getUserInfo($uid)
	{
		$service = new Mediad2_Service_Admin_User();
		return $service->getUserInfo($uid);
	}
	
	/**
	 * 获取用户已参加活动的列表
	 * @param int $uid
	 * @return Mediad2_Model_Result
	 */
	public function getEventIds($uid)
	{
		$service = new MM_Service_Admin_Event();
		return $service->getEventUserIds($uid);
	}
	
	/**
	 * 根据活动code显示所属用户的所有公开活动的列表
	 * @param string $qrcode
	 * @return Mediad2_Model_Result
	 */
	public function getEventByCode($qrcode)
	{
		$service = new MM_Service_Admin_Event();
		return $service->getEventByCode($qrcode);
	}
	
	/**
	 * follow event
	 * @param int $eid
	 * @param int $uid
	 * @return Mediad2_Model_Result
	 */
	public function followEvent($eid, $uid)
	{
		$service = new MM_Service_Admin_Event();
		return $service->followEvent($eid, $uid);
	}
	
	/**
	 * join event
	 * @param int $eid
	 * @param int $uid
	 * @return Mediad2_Model_Result
	 */
	public function joinEvent($eid, $uid ,$requestdata)
	{
		$service = new MM_Service_Admin_Event();
		return $service->joinEvent($eid, $uid,$requestdata);
	}
	
	/**
	 * quit event
	 * @param int $eid
	 * @param int $uid
	 * @return Mediad2_Model_Result
	 */
	public function quitEvent($eid, $uid)
	{
		$service = new MM_Service_Admin_Event();
		return $service->quitEvent($eid, $uid);
	}
	
	/**
	 * upload event photo
	 * @param int $eid
	 * @param int $esid
	 * @param int $uid
	 * @param string $desc
	 * @return Mediad2_Model_Result
	 */
	public function uploadEventFiles($eid, $esid, $uid, $desc)
	{
		$service = new MM_Service_Admin_EventFiles();
		return $service->uploadEventFiles($eid, $esid, $uid, $desc);
	}
	
	/**
	 * get event files list
	 * @param int $eid
	 * @param int $esid
	 * @param int $uid
	 * @param string $do
	 * @param int $addtime
	 * @return Mediad2_Model_Result
	 */
	public function getEventFiles($eid, $esid, $uid, $do, $addtime)
	{
		$service = new MM_Service_Admin_EventFiles();
		return $service->getEventFiles($eid, $esid, $uid, $do, $addtime);
	}
	
	/**
	 * get file info
	 * @param int $eid
	 * @param int $fid
	 * @return Mediad2_Model_Result
	 */
	public function getFilesInfo($eid, $fid)
	{
		$service = new MM_Service_Admin_EventFiles();
		return $service->getFilesInfo($eid, $fid);
	}
	
	/**
	 * update file desc
	 * @param int $fid
	 * @param int $uid
	 * @param string $filedesc
	 * @return Mediad2_Model_Result
	 */
	public function updateFilesDesc($fid,$uid,$filedesc)
	{
		$service = new MM_Service_Admin_EventFiles();
		return $service->updateFilesDesc($fid, $uid, $filedesc);
	}
	
	/**
	 * delete file
	 * @param int $fid
	 * @param int $uid
	 * @return Mediad2_Model_Result
	 */
	public function deleteFiles($fid,$uid)
	{
		$service = new MM_Service_Admin_EventFiles();
		return $service->deleteFiles($fid, $uid);
	}
	
	/**
	 * get file comment
	 * @param int $fid
	 * @param int $addtime
	 * @return Mediad2_Model_Result
	 */
	public function getFilesComment($fid, $addtime)
	{
		$service = new MM_Service_Admin_EventFiles();
		return $service->getFilesComment($fid, $addtime);
	}
	
	/**
	 * get file fav
	 * @param int $fid
	 * @param int $addtime
	 * @return Mediad2_Model_Result
	 */
	public function getFilesFav($fid, $addtime)
	{
		$service = new MM_Service_Admin_EventFiles();
		return $service->getFilesFav($fid, $addtime);
	}
	
	/**
	 * 喜欢/取消喜欢
	 * @param int $eid
	 * @param int $fid
	 * @param int $uid
	 * @param string $action
	 * @return Mediad2_Model_Result
	 */
	public function favorFiles($eid, $fid, $uid, $action)
	{
		$service = new MM_Service_Admin_EventFiles();
		return $service->favorFiles($eid, $fid, $uid, $action);
	}
	
	/**
	 * 评论/回复评论
	 * @param string $commentType
	 * @param int $eid
	 * @param int $uid
	 * @param string $objecttype
	 * @param int $objectid
	 * @param string $content
	 * @param int $reply_eucid
	 * @return Mediad2_Model_Result
	 */
	public function createComment($commentType='text', $eid, $uid, $objecttype, $objectid, $content='', $reply_eucid = 0)
	{
		$service = new MM_Service_Admin_EventUserComment();
		return $service->createComment($commentType, $eid, $uid, $objecttype, $objectid, $content, $reply_eucid);
	}
	
	/**
	 * 删除评论
	 * @param int $uid
	 * @param int $eucid
	 * @return Mediad2_Model_Result
	 */
	public function delComment($uid, $eucid)
	{
		$service = new MM_Service_Admin_EventUserComment();
		return $service->delComment($uid, $eucid);
	}
	
	/**
	 * get user files
	 * @param int $uid
	 * @param int $addtime
	 * @param int $needgroup
	 * @return Mediad2_Model_Result
	 */
	public function getUserFiles($uid, $addtime, $needgroup)
	{
		$service = new MM_Service_Admin_EventFiles();
		return $service->getUserFiles($uid, $addtime, $needgroup);
	}
	
	/**
	 * 增加Applause
	 * @param int $eid
	 * @param string $objecttype
	 * @param int $objectid
	 * @param string $applausetype
	 * @param int $number
	 * @return Mediad2_Model_Result
	 */
	public function addApplause($eid, $objecttype, $objectid, $applausetype="hand", $number = 1)
	{
		$service = new MM_Service_Admin_EventApplause();
		return $service->add($eid, $objecttype, $objectid, $applausetype, $number);
	}
	
	//---------------------------------------------------
	// 工具方法
	//---------------------------------------------------
	
	/**
	 * 指定用户是否已加入活动
	 * @param int $eid
	 * @param int $uid
	 * @return boolean
	 */
	public function isJoinedEvent($eid, $uid)
	{
		$service = new MM_Service_Admin_Event();
		return $service->isJoinedEvent($eid, $uid);
	}
	
	/**
	 * 指定用户是否已关注活动
	 * @param int $eid
	 * @param int $uid
	 * @return boolean
	 */
	public function isFollowedEvent($eid, $uid)
	{
		$service = new MM_Service_Admin_Event();
		return $service->isFollowedEvent($eid, $uid);
	}
	
	/**
	 * 上传文件
	 * @param int $sourcetype
	 * @param int $sourceid
	 * @param string $upload_name
	 * @param boolean $returnArray
	 * @return Mediad2_Model_Result
	 */
	public function upload($sourcetype, $sourceid, $upload_name='Filedata', $returnArray = false)
	{
		$service = new Mediad2_Service_Admin_Files();
		return $service->upload($sourcetype, $sourceid, $upload_name, $returnArray);
	}
	
	/**
	 * 下载文件
	 * @param int $fid
	 * @return Mediad2_Model_Result
	 */
	public function download($fid)
	{
		$service = new Mediad2_Service_Admin_Files();
		return $service->download($fid);	
	}

	
	//---------------------------------------------------
	// 私有方法
	//---------------------------------------------------
	
	public function funtemp()
	{
		try {
	
	
		} catch(Zend_Exception $e) {
			$this->handleException($e); //出错处理
			return $this->returnResult(Mediad2_Model_Result::CODE_FAILURE);	//返回结果--失败
		}
	}
	


}